package sk.stuba.fiit.foo07.genex.common;

/**
 * @author palo
 * 
 */
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class SettingsHelper {

    final static String settingsFilename = "genex.properties";
    static Properties Props;

    public static void setSetting(String key, String value) throws IOException {
        FileInputStream fis = new FileInputStream(settingsFilename);
        Props.load(fis);
        fis.close();
        Props.setProperty(key, value);
        FileOutputStream fos = new FileOutputStream(settingsFilename);
        Props.store(fos, "Genex settings");
        fos.close();
    }

    public static String getSetting(String key) throws IOException {
        FileInputStream fis = new FileInputStream(settingsFilename);
        Props.load(fis);
        fis.close();

        return Props.getProperty(key);
    }

    static {
        Props = new Properties();
    }
}
